#ifndef _VL_PROP_READER__H_
#define _VL_PROP_READER__H_

#include <cstdint>
#include <cstdlib>
#include <string>

namespace VL {

/**
 * @Author: CimZzz
 * @Date: 2023-03-15 09:23:11
 * 
 * 缓存长度
 */
#define _VL_PROP_READER_BUFF_SIZE 2048

/**
 * @Author: CimZzz
 * @Date: 2023-03-08 19:23:07
 * 
 * 属性 Reader
 */
class VLPropReader {
public:
	virtual ~VLPropReader();

	template<class T>
	T readNumber() {
		constexpr const int size = sizeof(T);
		T data = 0;
		for(int i = 0 ; i < size ; i ++) {
			T byte = this->read();
			if(i == 0) {
				data |= byte;
			} else {
				data = data | ((byte & 0xFF) << (8 * i));
			}
		}
		return data;
	}
	void readStr(std::string& str, size_t length);
	void readStrWithSize(std::string& str);
	virtual void readLine(std::string& line) = 0;
	virtual const bool isEof() const = 0; 
	virtual uint8_t read() = 0;
	virtual size_t readBuf(uint8_t* buf, size_t bufLength) = 0;

	uint8_t buf[_VL_PROP_READER_BUFF_SIZE];
};


}

#endif // _VL_PROP_READER__H_
